﻿using System;
using System.ServiceModel;
using EnterpriseServices.DalEf;
using System.Collections.Generic;

namespace EnterpriseServices.Service
{
    [ServiceContract(Name = "RoleManagerRemoting", Namespace = "http://EnterpriseServices.CodePlex.com/2009/03/06")]
    public interface IRoleManagerRemoting
    {
        /// <summary>
        /// Adds the specified users to the specified role.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userNames">The user names.</param>
        /// <param name="role">The role.</param>
        [OperationContract]
        void AddUsersToRole(string application, string[] userNames, string role);

        /// <summary>
        /// Adds the specified users to the specified roles.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userNames">The user names.</param>
        /// <param name="roles">The roles.</param>
        [OperationContract]
        void AddUsersToRoles(string application, string[] userNames, string[] roles);

        /// <summary>
        /// Adds the specified user to the specified role.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="role">The role.</param>
        [OperationContract]
        void AddUserToRole(string application, string userName, string role);

        /// <summary>
        /// Adds the specified user to the specified roles.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="roles">The roles.</param>
        [OperationContract]
        void AddUserToRoles(string application, string userName, string[] roles);

        /// <summary>
        /// Adds a new role to the data source.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="role">The role.</param>
        [OperationContract]
        void CreateRole(string application, string role);

        /// <summary>
        /// Removes a role from the data source. If throwOnPopulatedRole is true,throws an exception if roleName has one or more members.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="role">The role.</param>
        /// <param name="throwOnPopulatedRole">if set to <c>true</c> [throw on populated role].</param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteRole(string application, string role, bool throwOnPopulatedRole);

        /// <summary>
        /// Removes all the roles from the data source. If throwOnPopulatedRole is true,throws an exception if any of the roles has one or more members
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="throwOnPopulatedRole">if set to <c>true</c> [throw on populated role].</param>
        [OperationContract]
        void DeleteAllRoles(string application, bool throwOnPopulatedRole);
        
        /// <summary>
        /// Gets a list of all the roles for the application.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        [OperationContract]
        List<Role> GetAllRoles(string ApplicationName);

        /// <summary>
        /// Gets a list of the roles that a user is in.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        [OperationContract]
        List<Role> GetRolesByUser(string ApplicationName, string UserName);

        /// <summary>
        /// Gets a list of users in the specified role.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="role">The role.</param>
        /// <returns></returns>
        [OperationContract]
        List<User> GetUsersInRole(string ApplicationName, string RoleName);

        /// <summary>
        /// Removes the specified user from the specified role.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="roleName">Name of the role.</param>
        [OperationContract]
        void RemoveUserFromRole(string application, string userName, string roleName);

        /// <summary>
        /// Removes the specified users from the specified role.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="users">The users.</param>
        /// <param name="role">The role.</param>
        [OperationContract]
        void RemoveUsersFromRole(string application, string[] users, string role);

        /// <summary>
        /// Removes the specified user from the specified roles.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="user">The user.</param>
        /// <param name="roles">The roles.</param>
        [OperationContract]
        void RemoveUserFromRoles(string application, string user, string[] roles);

        /// <summary>
        /// Removes the specified user names from the specified roles.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="users">The users.</param>
        /// <param name="roles">The roles.</param>
        [OperationContract]
        void RemoveUsersFromRoles(string application, string[] users, string[] roles);

        /// <summary>
        /// Returns true if role management is enabled; otherwise,false
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns>
        /// 	<c>true</c> if [is roles enabled] [the specified application]; otherwise, <c>false</c>.
        /// </returns>
        [OperationContract]
        bool IsRolesEnabled(string application);

        /// <summary>
        /// Returns true if the role name already exists in the data source; otherwise,false.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="role">The role.</param>
        /// <returns></returns>
        [OperationContract]
        bool RoleExists(string application, string role);
    }
}
